import { PropertyKey } from "@/constants/Enums";
import { editorMap } from ".";

/**
 * 属性key到组件的映射
 */
export const PropertyKeyToEditor = {
  [PropertyKey.Package_packagedElement]: editorMap.Elements_Create,

  // 右侧有个下拉菜单，选择模型类型，多选插入
  [PropertyKey.CallAction_result]: editorMap.Models_RightDropdown,
  [PropertyKey.Element_appliedStereotype]: editorMap.Element_AppliedStereotype,
  [PropertyKey.Customization_MetaClassFilter_SelectedMetaClass]: editorMap.Element_ElementsAndStereotypes,
  [PropertyKey.Customization_StereotypeFilter_SelectedStereotype]: editorMap.Element_ElementsAndStereotypes,
  [PropertyKey.Element_image]: editorMap.Image,
  [PropertyKey.Stereotype_icon]: editorMap.Image,
  [PropertyKey.Customization_AttachedFile_attachedAt]: editorMap.DateEditor,
  [PropertyKey.Customization_AttachedFile_modifiedAt]: editorMap.DateEditor,
  [PropertyKey.AdornmentRule_adornment]: editorMap.Adornment,
  [PropertyKey.SysML_Block_isEncapsulated]: editorMap.Checkbox,
  [PropertyKey.UseCase_extensionPoint]: editorMap.AddProperty,
  [PropertyKey.Element_activeHyperLink]: editorMap.HyperlinkSelect,

  [PropertyKey.Comment_body]: editorMap.Textarea,
  [PropertyKey.AbstractRequirement_text]: editorMap.Textarea,
  [PropertyKey.Customization_Term_Description]: editorMap.Textarea,
  [PropertyKey.AbstractRequirement_reqId]: editorMap.RequirementId,
  [PropertyKey.OpaqueAction_language]: editorMap.LanguageSelectInput,

  [PropertyKey.OpaqueBehavior_language]: editorMap.LanguageSelectInput,
  [PropertyKey.OpqaueExpression_language]: editorMap.LanguageSelectInput,
  [PropertyKey.NamedElement_visibility]: editorMap.Select,
  [PropertyKey.PackageImport_visibility]: editorMap.Select,

  [PropertyKey.Parameter_effect]: editorMap.Select,
  [PropertyKey.ExpansionRegion_mode]: editorMap.Select,

  [PropertyKey.Property_aggregation]: editorMap.Select,
  [PropertyKey.PackageableElement_visibility]: editorMap.Select,
  [PropertyKey.Customization_DiagramTypeFilter_DiagramType]: editorMap.Select,
  [PropertyKey.SysML_FlowPort_direction]: editorMap.Select,

  [PropertyKey.TypedElement_type]: editorMap.Model_DropdownSearch,

  [PropertyKey.Transition_guard]: editorMap.ValueSpecification,
  [PropertyKey.Message_guard]: editorMap.ValueSpecification,

  [PropertyKey.Parameter_direction]: editorMap.Select,
  [PropertyKey.Transition_kind]: editorMap.Select,

  [PropertyKey.BehavioralFeature_concurrency]: editorMap.Select,

  [PropertyKey.SysML_ProxyPort_direction]: editorMap.Select,
  [PropertyKey.BlackBoxICDTable_port_direction]: editorMap.Select,
  // 需求追溯图
  [PropertyKey.DiagramMap_direction]: editorMap.Select,
  [PropertyKey.DiagramMap_elementTypes]: editorMap.DiagramMapRowElementType,
  [PropertyKey.DiagramMap_displayedAttributes]: editorMap.DiagramMapDisplayedAttributes,
  [PropertyKey.DiagramMap_relationCriterion]: editorMap.DiagramMapRelationCriterion,

  //
  // [PropertyKey.Trigger_eventType]: editorMap.Select,
  [PropertyKey.CombinedFragment_interactionOperator]: editorMap.Select,

  [PropertyKey.Property_redefinedProperty]: editorMap.Models_TreeSelect,
  [PropertyKey.Connector_kind]: editorMap.Select,
  // 右侧有个下拉菜单，选择模型类型
  [PropertyKey.Property_defaultValue]: editorMap.ValueSpecification,
  [PropertyKey.Parameter_defaultValue]: editorMap.ValueSpecification,
  [PropertyKey.ActivityEdge_guard]: editorMap.ValueSpecification,
  [PropertyKey.JoinNode_joinSpec]: editorMap.ValueSpecification,
  [PropertyKey.Duration_expr]: editorMap.ValueSpecification,
  [PropertyKey.IntervalConstraint_specification]: editorMap.ValueSpecification,
  [PropertyKey.TimeExpression_expr]: editorMap.ValueSpecification,
  [PropertyKey.Extend_condition]: editorMap.ValueSpecification,
  [PropertyKey.ProtocolTransition_postCondition]: editorMap.ValueSpecification,
  [PropertyKey.ProtocolTransition_preCondition]: editorMap.ValueSpecification,
  [PropertyKey.State_stateInvariant]: editorMap.ValueSpecification,
  [PropertyKey.InteractionOperand_guard]: editorMap.ValueSpecification,
  [PropertyKey.InteractionUse_returnValue]: editorMap.ValueSpecification,
  [PropertyKey.Lifeline_selector]: editorMap.ValueSpecification,
  [PropertyKey.StateInvariant_invariant]: editorMap.ValueSpecification,
  [PropertyKey.Abstraction_mapping]: editorMap.ValueSpecification,
  [PropertyKey.Constraint_specification]: editorMap.ValueSpecification,
  [PropertyKey.ChangeEvent_changeExpression]: editorMap.ValueSpecification,
  [PropertyKey.InstanceSpecification_specification]: editorMap.ValueSpecification,
  [PropertyKey.Operation_bodyCondition]: editorMap.ValueSpecification,
  [PropertyKey.WriteVariableAction_value]: editorMap.ValueSpecification,
  [PropertyKey.ValuePin_value]: editorMap.ValueSpecification,
  [PropertyKey.MultiplicityElement_lowerValue]: editorMap.ValueSpecification,
  [PropertyKey.MultiplicityElement_upperValue]: editorMap.ValueSpecification,
  [PropertyKey.ValueSpecificationAction_value]: editorMap.ValueSpecification,

  [PropertyKey.LoopNode_loopVariable]: editorMap.Models_TreeSelect,
  [PropertyKey.LoopNode_result]: editorMap.Models_TreeSelect,
  [PropertyKey.StructuredActivityNode_structuredNodeOutput]: editorMap.Models_TreeSelect,

  //
  [PropertyKey.SysML_FlowProperty_direction]: editorMap.Select,
  [PropertyKey.Message_messageSort]: editorMap.Select,
  // 多重性
  [PropertyKey.MultiplicityElement_multiplicity]: editorMap.MultiplicityElement_multiplicity,

  [PropertyKey.DiagramMatrix_direction]: editorMap.Select,
  [PropertyKey.DiagramMatrix_rowElementType]: editorMap.DiagramMatrix_rowElementType,
  [PropertyKey.DiagramMatrix_columnElementType]: editorMap.DiagramMatrix_rowElementType,
  [PropertyKey.DiagramMatrix_relationCriterion]: editorMap.DiagramMatrix_relationCriterion,
  [PropertyKey.ValidationRule_validationRule]: editorMap.DiagramMatrix_relationCriterion,
  [PropertyKey.DiagramMatrix_showElements]: editorMap.Select,
  [PropertyKey.DiagramMatrix_rowCollapsedNodes]: editorMap.Models_TreeSelect,
  [PropertyKey.DiagramMatrix_columnCollapsedNodes]: editorMap.Models_TreeSelect,

  // 表格属性
  [PropertyKey.DiagramTable_rowElementType]: editorMap.Element_TreeSelect,
  [PropertyKey.DiagramTable_displayMode]: editorMap.Select,
  [PropertyKey.InstanceTableSlot_value]: editorMap.SlotEditorForInstanceTable,
  [PropertyKey.ActualMeasuresTable_Measure]: editorMap.SlotEditorForInstanceTable,
  [PropertyKey.ValidationRule_validationObjectType]: editorMap.Element_TreeSelect,
  // 自定义的itemflow属性

  [PropertyKey.ItemFlow_name]: editorMap.Select,
  [PropertyKey.ItemFlow_direction]: editorMap.Select,
  [PropertyKey.Pseudostate_kind]: editorMap.Select,
  [PropertyKey.NamedElement_name]: editorMap.NamedElement_name,
  [PropertyKey.DurationConstraint_specification]: editorMap.Input_specification,
  [PropertyKey.TimeConstraint_specification]: editorMap.Input_specification,

  [PropertyKey.DurationInterval_max]: editorMap.Input_specification,
  [PropertyKey.DurationInterval_min]: editorMap.Input_specification,
  [PropertyKey.TimeEvent_when]: editorMap.Input_specification,
  [PropertyKey.Customization_PropertyGroup_properties]: editorMap.PropertyGroupProperties,
  [PropertyKey.Customization_PropertyGroup_columns]: editorMap.PropertyGroupColumns,

  [PropertyKey.Legend_legendItems]: editorMap.LegendItem,
  [PropertyKey.LegendItem_condition]: editorMap.LegendItem_condition,

  // 以下组件与模型树渲染一致
  [PropertyKey.Element_ownedElement]: editorMap.PropertyNodeLabel,
  [PropertyKey.Namespace_packageImport]: editorMap.PropertyNodeLabel,
  [PropertyKey.Slot_value]: editorMap.ModelsRightDropdownNodeLabel,
  [PropertyKey.InstanceSpecification_slot]: editorMap.PropertyNodeLabel,
  [PropertyKey.InteractionFragment_covered]: editorMap.ModelsTreeSelectNodeLabel,
  [PropertyKey.ConnectorEnd_partWithPort]: editorMap.PropertyNodeLabel,
  [PropertyKey.NamedElement_clientDependency]: editorMap.PropertyNodeLabel,
  ["UAF::Architecture Management::Taxonomy::ActualState::startDate"]: editorMap.TimePoint,
  ["UAF::Architecture Management::Taxonomy::ActualState::endDate"]: editorMap.TimePoint,

  [PropertyKey.SysML_VerifyMethod_Property]: editorMap.Select,
  [PropertyKey.SysML_Risk_Property]: editorMap.Select,
  [PropertyKey.Stereotype_defaultName]: editorMap.NamedElement_name,
  [PropertyKey.Customization_Customization_keyword]: editorMap.Input,

  [PropertyKey.MetaConfig_diagramConfig]: editorMap.DiagramCustomization,
  [PropertyKey.Customization_Banner_text]: editorMap.PropertyBanner,
  [PropertyKey.MetaConfig_shapeMenuConfig]: editorMap.ShapeMenuConfig,
  [PropertyKey.MetaConfig_shapeConfig]: editorMap.ShapeCustomization,
  [PropertyKey.Customization_ConstraintConfig_value]: editorMap.ValueSpecification,
  [PropertyKey.Customization_ConstraintConfig_instanceId]: editorMap.Model_TreeSelect,
  [PropertyKey.Customization_ConstraintConfig_lower]: editorMap.InputNumber,
  [PropertyKey.Customization_ConstraintConfig_upper]: editorMap.InputNumber,

  [PropertyKey.Customization_DerivedPropertySpecification_expression]: editorMap.Expression,
  [PropertyKey.InteractionConstraint_maxint]: editorMap.ValueSpecification,
  [PropertyKey.InteractionConstraint_minint]: editorMap.ValueSpecification,
  [PropertyKey.InteractionUse_argument]: editorMap.ValueSpecification,
  [PropertyKey.TemplateParameter_ownedDefault]: editorMap.ValueSpecification,
  ["UAF::Projects::Roadmap::ActualProjectMilestone::endDate"]: editorMap.TimePoint,
  ["UAF::Personnel::Traceability::ResponsibleFor::endDate"]: editorMap.TimePoint,
  ["UAF::Actual Resources::Connectivity::FillsPost::endDate"]: editorMap.TimePoint,
  ["UAF::Personnel::Traceability::ResponsibleFor::startDate"]: editorMap.TimePoint,
  ["UAF::Actual Resources::Connectivity::FillsPost::startDate"]: editorMap.TimePoint,
  ["UAF::Standards::Taxonomy::Standard::mandatedDate"]: editorMap.TimePoint,
  ["UAF::Standards::Taxonomy::Standard::retiredDate"]: editorMap.TimePoint,
  ["ActualMeasuresTable-StartDate"]: editorMap.TimePoint,
  ["ActualMeasuresTable-EndDate"]: editorMap.TimePoint,
  ["16913455820160"]: editorMap.ValueSpecification,
  ["16913459895424"]: editorMap.ValueSpecification,
  ["16913459941440"]: editorMap.ValueSpecification,
  ["78900938154478976"]: editorMap.TrackEditor,
  ["81437926063640704"]: editorMap.TrackEditor,
  [PropertyKey.State_doActivity]: editorMap.SelectStateActivity,

  [PropertyKey.SysML_ItemFlow_fromActivity]: editorMap.SpecifyActivityProperty,
  [PropertyKey.SysML_ItemFlow_toActivity]: editorMap.SpecifyActivityProperty,
  [PropertyKey.Customization_GetProperties_Property]: editorMap.Model_GetProperties,

  [PropertyKey.ReliabilityProfile_FMEA_Profile_FMEAItem_ESR]: editorMap.ReliabilitySelect,
  [PropertyKey.ReliabilityProfile_FMEA_Profile_FMEAItem_DET]: editorMap.ReliabilitySelect,
  [PropertyKey.ReliabilityProfile_FMEA_Profile_FMEAItem_OPR]: editorMap.ReliabilitySelect,
  [PropertyKey.ReliabilityProfile_FMEA_Profile_CauseOfFailure_premitigationOccurrences]: editorMap.SelectRows, // 故障原因的预防前故障发生次数
  [PropertyKey.ReliabilityProfile_FMEA_Profile_CauseOfFailure_occurrence]: editorMap.ReliabilitySelect, // 故障原因的发生次数
  [PropertyKey.ReliabilityProfile_FMEA_Profile_Event_priority]: editorMap.ReliabilitySelect, // 事件的优先级
  [PropertyKey.ReliabilityProfile_FMEA_Profile_FinalEffectOfFailure_Severity]: editorMap.ReliabilitySelect, // 最终影响的严重程度
  [PropertyKey.ReliabilityProfile_FMEA_Profile_FinalEffectOfFailure_premitigationSeverity]: editorMap.SelectRows, // 最终影响的预防前严重程度
  [PropertyKey.NumberPart_initialValue]: editorMap.SequenceCommonComp,
  [PropertyKey.AutoNumber_prefix]: editorMap.PrefixTextArea,
  [PropertyKey.NumberPart_sequence]: editorMap.SequenceCommonComp,
  [PropertyKey.PropertySyncRule_targetProperty]: editorMap.ElementSyncMap,
  [PropertyKey.PropertySyncRule_sourceProperty]: editorMap.ElementSyncMap,
  [PropertyKey.Trigger_eventType]: editorMap.TriggerEventType,

};

// 内置的模型属性 只有一部分允许使用富文本编辑，
// 用户自定义的属性，排除在notHtmlPropertyKeys范围内的，只要类型是string的，就允许使用富文本,
/**
 * 是html编辑的属性
 */
export const htmlPropertyKeys = new Set<string>([PropertyKey.AbstractRequirement_text, PropertyKey.Customization_Term_Description]);

/**
 * 不是html编辑的属性
 */
export const notHtmlPropertyKeys = new Set<string>(["87691457310863808"]);
